const Banner = require("../model/banner");
const formidable = require('formidable'); //处理含有文件上传的表单
const path = require('path');
const uuid = require('uuid'); //产生唯一字符串
const fs = require('fs');

/**
 * 文章中间件
 */
module.exports = {
    // 获取全部轮播图
    getBanner: (req, res, next) => {
        Banner.getBanner()
            .then((res) => {
                req.bannerList = res;
                next();
            })
            .catch((err) => {
                next(err);
            });
    },
    updateBanner: (req, res, next) => {
      const bannerList = req.body;
      console.log(req.body);
      Banner.updateBanner(bannerList)
            .then((res) => {
                req.data = res;
                next();
            })
            .catch((err) => {
                next(err);
            });
    }
}